{temp('admin/head')}

</head>
<body class="page-body" {if($qx !== 0)}onload="aa()"{/if}>
	
			
		{temp('admin/left')}

			{temp('admin/top')}

			{if(@$r)}
			<div class="row">
				<div class="col-sm-12">
					
					<div class="panel panel-default">
						<div class="panel-heading">
							<h3 class="panel-title">{$tit}</h3>
						</div>
						<div class="panel-body">							
							<div class="form-horizontal">
								<div class="form-group">
									<label class="col-sm-2 control-label" for="field-1">账号</label>
									
									<div class="col-sm-10">
										<input type="text" id="name" class="form-control" style="width:30%;" value="{$r['name']}"/>
									</div>
								</div>
								
								<input type="hidden" id="day" value='{$qx}'/>
								<div class="form-group">
									<label class="col-sm-2 control-label">权限</label>
									
									<div class="col-sm-10" style="padding-left:6px;">
										<p>
										{if(@$wzgn)}
											{foreach($wzgn as $k=>$v)}
											<label class="checkbox-inline" style="margin-left:10px;">
												<input type="checkbox" value="{$v['id']}" name="qx" id="gn_{$v['id']}" />
												{$v['name']}
											</label>
											{/foreach}
									    {/if}
										</p>
									</div>
								</div>
								
								<script type="text/javascript">
									function aa(){
										var a = JSON.parse(document.getElementById('day').value);
										var checklist=document.getElementsByName('qx');
										for(var j=0;j<checklist.length;j++){
											if(jQuery.inArray(checklist[j].value,a) >= 0){
												checklist[j].checked=1;
											}
										}
									}
								</script>
								
								<div class="form-group-separator"></div>
								
								<div class="form-group">
									<div class="col-sm-10">
										<button class="btn btn-info btn-single pull-right" onclick="xg({$r['id']})" type="button">提交</button>
									</div>
								</div>
							</div>							
						</div>
					</div>
					
				</div>
			</div>
			<script type="text/javascript">
			
			</script>
			{/if}

		{temp('admin/foot')}
		
	<script type="text/javascript">
		function xg(id){
			var name = $("#name").val();
			var qx =[];//定义一个数组
			$('input[name="qx"]:checked').each(function(){//遍历每一个名字为interest的复选框，其中选中的执行函数
				qx.push($(this).val());//将选中的值添加到数组chk_value中
			});
			$.post('/admin/?act=xitong&met=zu_xg{$gnpd}',{id:id,name:name,qx:qx},function(data){
				if(data == 'cg'){
					alert('修改成功');
					location.href = '/admin/?act=xitong&met=zu{$gnpd}';
				}else if(data == 'error'){
					alert('修改失败');
				}else if(data == '-1'){
					alert('组名称不能为空');
				}else if(data == '-2'){
					alert('权限不能为空');
				}
			});
		}
	</script>
	<!-- Bottom Scripts -->
	<script src="{$adstyle}/js/bootstrap.min.js"></script>
	<script src="{$adstyle}/js/TweenMax.min.js"></script>
	<script src="{$adstyle}/js/resizeable.js"></script>
	<script src="{$adstyle}/js/joinable.js"></script>
	<script src="{$adstyle}/js/xenon-api.js"></script>
	<script src="{$adstyle}/js/xenon-toggles.js"></script>

	<!-- Imported scripts on this page -->
	<script src="{$adstyle}/js/select2/select2.min.js"></script>

	<!-- JavaScripts initializations and stuff -->
	<script src="{$adstyle}/js/xenon-custom.js"></script>
</body>
</html>